package com.lagou.client;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.List;

public class ReadList {

    // 返回值类型为泛型的Student
    public static List<Student> rdList() {
        ObjectInputStream in = null;
        List<Student> list =null;

        try {
            in = new ObjectInputStream(new FileInputStream("D:/a.txt"));
            // 读取文件
            Object obj = in.readObject();
            // 获取集合对象
            list = (List<Student>)obj;
        } catch (IOException | ClassNotFoundException e) {
            e.printStackTrace();
        } finally {
            if (null != in) {
                try {
                    in.close();

                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        // 返回集合对象
        return list;
    }
}

